package com.project.taohaoCoupons.merchant.admin.controller;

import com.project.taohaoCoupons.framework.idempotent.NoDuplicateSubmit;
import com.project.taohaoCoupons.framework.result.Result;
import com.project.taohaoCoupons.framework.web.Results;
import com.project.taohaoCoupons.merchant.admin.dto.req.CouponTemplateNumberReqDTO;
import com.project.taohaoCoupons.merchant.admin.dto.req.CouponTemplateSaveReqDTO;
import com.project.taohaoCoupons.merchant.admin.service.CouponTemplateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/merchant-admin/couponTemplate")
@Tag(name="优惠券模板管理")
@RequiredArgsConstructor
public class CouponTemplateController {

    private final CouponTemplateService couponTemplateService;

    @Operation(summary = "创建优惠券模板")
    @NoDuplicateSubmit(message = "短时间重复创建优惠券模板，请稍等")
    @PostMapping("/create")
    public Result<Void> createCouponTemplate(@RequestBody CouponTemplateSaveReqDTO requestParam) {
        couponTemplateService.createCouponTemplate(requestParam);
        return Results.success();
    }


    @Operation(summary = "结束优惠券模板")
    @PostMapping("/terminate")
    public Result<Void> endCouponTemplate(String couponTemplateId) {
        couponTemplateService.terminateCouponTemplate(couponTemplateId);
        return Results.success();
    }
    @Operation(summary = "增加优惠券模板发行量")
    @NoDuplicateSubmit(message = "请勿短时间内重复增加优惠券发行量")
    @PostMapping("increase-number")
    public Result<Void> increaseNumberCouponTemplate(@RequestBody CouponTemplateNumberReqDTO requestParam) {
        couponTemplateService.increaseNumberCouponTemplate(requestParam);
        return Results.success();
    }
}
